package edu.sctu.nieyu.day20150522;

/**
 * Created by user01 on 2015/5/24.
 */
public class TextOne extends TextMore {
    Student[] studentcode1 = new Student[teacher[0].student.length];
    Student[] studentcode3 = new Student[6];

    public TextOne(Teacher[] teacher){
        super(teacher);
    }
    public void getTeacherInfo(){

        sotrNumber();
        System.out.println("老师学号排序: \n姓名："+teacher[0].name+"\t学号："+teacher[0].number+"\n姓名："+teacher[1].name+"\t学号："+teacher[1].number);
    }
    public Student[] getStudent(int code,Student[] student){
        System.out.println("成绩大于code：");
        Student[] studentcode1 = new Student[student.length];
        for(int i=0;i<student.length;i++){
            if(student[i].grade>code){
                studentcode1[i] = student[i];

                System.out.println("姓名："+student[i].name+"\t学号:"+student[i].number+"\t成绩："+student[i].grade);
            }
        }
        return studentcode1;
    }
    public Student[] getCode(){
        Teacher teacher = pritCoded();
        Student[] studentnumber = interFace.getStudents(teacher.student);
        return studentnumber;
    }
    InterStudent interFace = new InterStudent(){
        public Student[] getStudents(Student[] student){
            Student[] studentnumber = getStudent(60,student);
            return studentnumber;
        }
    };


    public void getCourse(Teacher[] teachers) {
        int result1 = 0;
        int result2 = 0;
        int result3 = 0;
        int result4 = 0;

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (teachers[i].student[j].Course[k].getCourse() == "计算机") {
                        result1 = result1 + 1;
                    }
                    if (teachers[i].student[j].Course[k].getCourse() == "语文") {
                        result2 = result2 + 1;
                    }
                    if (teachers[i].student[j].Course[k].getCourse() == "数学") {
                        result3 = result3 + 1;
                    }
                    if (teachers[i].student[j].Course[k].getCourse() == "物理") {
                        result4 = result4 + 1;
                    }
                }
            }
        }
        int judge1 = 0;
        int judge2 = 0;
        int judge3 = 0;

        judge1 = result1 > result2 ? result1 : result2;
        judge2 = result3 > result4 ? result3 : result4;
        judge3 = judge1 > judge2 ? judge1 : judge2;

        if (judge3 == result3) {
            System.out.println("数学课程人数最多，人数："+result3);
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (teachers[i].student[j].Course[k].getCourse() == "数学") {
                        System.out.println(teachers[i].name + "的学生：" + teachers[i].student[j].name);
                    }
                }
            }
        }
        }if (judge3 == result1){
            System.out.println("计算机人数最多，人数为："+result1);
            for (int i = 0; i <2 ; i++) {
                for (int j = 0; j <3 ; j++) {
                    for (int k = 0; k <3 ; k++) {
                        if (teachers[i].student[j].Course[k].getCourse() =="计算机"){
                            System.out.println(teachers[i].name+"的学生"+teachers[i].student[j].name);
                        }

                    }

                }

            }
        }if (judge3 == result2){
            System.out.println("\t"+"语文人数也多，它的人数为："+result2);
            for (int i = 0; i <2 ; i++) {
                for (int j = 0; j <3 ; j++) {
                    for (int k = 0; k <3 ; k++) {
                        if (teachers[i].student[j].Course[k].getCourse() =="语文"){
                            System.out.println("\t"+teachers[i].name+"的学生："+teachers[i].student[j].name);
                        }

                    }

                }

            }
        }

    }



}
